package com.yunzone.cloud.modules;


import com.yunzone.cloud.common.entity.Result;
import com.yunzone.cloud.modules.payment.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/payment")
public class PaymentController {
    @Value("${server.port}")
    private String port;

    public static HashMap<Long, Payment> hashMap = new HashMap<>();

    static {
        hashMap.put(1L, new Payment(1L, " 28a8c1e3bc2742d8848569891fb42181"));
        hashMap.put(2L, new Payment(2L, "bba8c1e3bc2742d8848569891ac32182"));
        hashMap.put(3L, new Payment(3L, "6ua8c1e3bc2742d8848569891xt92183"));
    }

    @RequestMapping("/query/{id}")
    public Result<Payment> query(@PathVariable("id") Long id) {
        Payment payment = hashMap.get(id);
        return new Result<Payment>(200, true, "查询成功！，服务来自于端口:"+port, payment);
    }
}
